// ============================== 导入依赖 ============================== //

import state from '@admin/views/Maintain/Knowledge/KnowledgeCategory/store/state'

// ============================== 导出状态集 ============================== //

export default {
  // —————————————————————————————— 常量状态 —————————————————————————————— //

  /**
   * 接口
   */
  API: {
    ...state.API,

    transTree(arr) { // 过滤没有第三层节点的二级节点
      arr.forEach((major) => {
        if (!major.children) return
        major.children = major.children.filter((minor) => minor.children && minor.children.length)
      })
      return arr.filter((major) => major.children && major.children.length)
    },
  },

  /**
   * 映射
   */
  MAP: state.MAP,

  /**
   * 结构树字段 (可增加)
   */
  TREE_FIELD: ['children', 'id', 'baseTypeLabel', 'baseTypeCode'],
}
